# -*- coding: UTF-8 -*-

import utils
import mashups
import web_apis

class User:
    def __init__(self):
        self.user_dict = {}
        self.user_heat = {}
        users = utils.load_json('users.json')
        self.total_count = 0
        print('start read user')
        for user_struct in users:
            self.total_count += 1
            if (self.total_count % 5000 == 0):
                print('read user count=', self.total_count)
            if 'url' in user_struct and 'followers' in user_struct:
                user_name = utils.get_clean_data_from_url(user_struct['url'])
                self.user_dict[user_name] = [utils.get_clean_data_from_url(raw) for raw in user_struct['followers']]
                self.user_heat[user_name] = len(self.user_dict[user_name])
        print('end read user')


if __name__ == "__main__":
    ma = mashups.Mashups()
    wa = web_apis.Web_APIs()
    category = {}
    arch = {}
    fmt = {}
    for m in ma.mashup_dict.values():
        for c in m['category']:
            category[c] = True
    print(len(category))
    for w in wa.api_dict.values():
        for c in w['category']:
            category[c] = True
        if 'architecture' in w:
            for a in w['architecture']:
                arch[a] = True
        if 'request_format' in w:
            for rf in w['request_format']:
                fmt[rf] = True
        if 'response_format' in w:
            for sf in w['response_format']:
                fmt[sf] = True
    
    print(len(category))
    print(len(arch))
    print(len(fmt))